package ihm;

import java.awt.CardLayout;

import javax.swing.GroupLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import database.DataBase;

public class MainFrame extends javax.swing.JFrame{

	JPanel pan;
	String db;
	
	public MainFrame(String file){
		super();
		db=file;
		
		pan=new JPanel();
		pan.setLayout(new CardLayout());
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		JPanel fragmentPanel=new FragmentPanel(this);
		this.setTitle("Add or Edit a Fragment");
		
		//panels creation
		JPanel metrics=new MetricsPanel(this);
		pan.add(fragmentPanel, "fragmentPanel");
		pan.add(metrics, "metricPanel");
		
		GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(50, 50, 50)
                .addComponent(pan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(230, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(50, 50, 50)
                .addComponent(pan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(57, Short.MAX_VALUE))
        );
        pack();
	}
	
	public JPanel getPan(){
		return pan;
	}
	
	public String getDbFile(){
		return db;
	}
	
	public void setTitleToFragmentPanel(){
		this.setTitle("Add or Edit a Fragment");
	}
	
	public void setTitleToMetricsPanel(){
		this.setTitle("Choose a metric");
	}
	
	
}
